package com.cxyd.modules.wcs.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.cxyd.common.page.PageData;
import com.cxyd.common.service.impl.CrudServiceImpl;
import com.cxyd.modules.wcs.dao.AgvRouteHkDao;
import com.cxyd.modules.wcs.dto.AgvRouteHkDTO;
import com.cxyd.modules.wcs.entity.AgvRouteHkEntity;
import com.cxyd.modules.wcs.service.AgvRouteHkService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class AgvRouteHkServiceImpl extends CrudServiceImpl<AgvRouteHkDao, AgvRouteHkEntity, AgvRouteHkDTO> implements AgvRouteHkService {
    @Override
    public QueryWrapper<AgvRouteHkEntity> getWrapper(Map<String, Object> params) {
        String carryNo = (String) params.get("carryNo");
        String taskTyp = (String) params.get("taskTyp");
        QueryWrapper<AgvRouteHkEntity> wrapper = new QueryWrapper<>();
        wrapper.eq(StringUtils.isNotBlank(carryNo), "carry_no", carryNo);
        wrapper.like(StringUtils.isNotBlank(taskTyp), "task_typ", taskTyp);
        return wrapper;
    }

    @Override
    public PageData<AgvRouteHkDTO> page(Map<String, Object> params) {
        return super.page(params);
    }

    @Override
    public List<AgvRouteHkEntity> getListByTaskTyp(String taskTyp) {
        QueryWrapper<AgvRouteHkEntity> qw = new QueryWrapper<>();
        qw.lambda().eq(AgvRouteHkEntity::getTaskTyp, taskTyp)
                .eq(AgvRouteHkEntity::getStatus, 0)
                .orderBy(true, true, AgvRouteHkEntity::getSortNum);
        return baseDao.selectList(qw);
    }
}
